
ALTER        proc sp_save_customer_details_for_backlog 
@sales_person varchar(30),
@contact_person varchar(30),
@phone_number varchar (30),
@fax_number varchar(30),
@email varchar(40),
@address1 varchar (50),
@address2 varchar(50),
@city varchar (30),
@state varchar(30),
@zipcode varchar(30),
@country varchar(30),
@customer_id int 


as
begin
	declare @sales_order_id int, @billing_address_id int
	declare salesOrderIdCursor CURSOR for
		select distinct SalesOrder_ID from fn_load_view_orders(0,0,1,'Backlog') where fn_load_view_orders.Customer_ID = @customer_id
		--select distinct SalesOrder_ID  from fn_load_view_orders(0,0,1,'Backlog') where fn_load_view_orders.Customer_ID = 114

	open salesOrderIdCursor
		fetch next from salesOrderIdCursor into @sales_order_id
		while @@fetch_status= 0
		begin
			-- Update only the backlog orders in sales_order table. Populate it with new values entered through the customer details screen
			--update sales_order set SO_Contact_Person =@contact_person,SO_Sales_Person =@sales_person  
				--where SalesOrder_ID = @sales_order_id
			
		fetch next from salesOrderIdCursor into @sales_order_id
		end
	
	close salesOrderIdCursor
	deallocate salesOrderIdCursor
end

